package com.lightjet.macross.base.upms.service.impl;

import com.lightjet.macross.base.upms.domain.AppClient;
import com.lightjet.macross.base.upms.repository.AppClientRepository;
import com.lightjet.macross.base.upms.service.AppClientService;
import com.lightjet.macross.common.core.BaseServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("appClientServiceImpl")
public class AppClientServiceImpl extends BaseServiceImpl<AppClient,Integer> implements AppClientService {


    @Cacheable(value = "app_client", key = "'clientid:'+#clientid", unless = "#result eq null")
    @Override
    public AppClient FindByClientid(String clientid) {
        return ((AppClientRepository) baseRepository).findByClientid(clientid);
    }

    @Override
    public List<AppClient> FindByKeywords(String keywords) {
        return ((AppClientRepository) baseRepository).findByKeywords(keywords);
    }

    @Override
    public AppClient FindDistinctById(Integer id) {
        return ((AppClientRepository) baseRepository).findDistinctById(id);
    }

    @Override
    @CacheEvict(value = "app_client", key = "'clientid:'+ #appClient.clientId")
    public void DeleteSingle(AppClient appClient) {
        this.DeleteOne(appClient);
    }

    @Override
    @CacheEvict(value = "app_client", key = "'clientid:'+ #appClient.clientId")  // 注意这里domain类里get方法重写了Id 首字母大写了
    public AppClient UpdateSingle(AppClient appClient) {
        return UpdateAndFlush(appClient);
    }


}
